package view_api

import (
	"gin-vue-admin/global"
	"gin-vue-admin/model"
	"gin-vue-admin/model/response"
	"gin-vue-admin/service"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

func UserCreateProject(c *gin.Context) {
	var userProject model.UserProject
	_ = c.ShouldBindJSON(&userProject)
	userProject.NowStatus = 10
	if err := service.CreateUserProject(userProject); err != nil {
		global.GVA_LOG.Error("申请失败!", zap.Any("err", err))
		response.FailWithMessage("申请失败", c)
	} else {
		response.OkWithMessage("申请成功", c)
	}
}

func GetUserProject(c *gin.Context){
	var userProject model.UserProject
	_ = c.ShouldBindQuery(&userProject)
	if err, reuserProject := service.GetUserProject(userProject.ID); err != nil {
		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
		response.FailWithMessage("查询失败", c)
	} else {
		response.OkWithData(gin.H{"reuserProject": reuserProject}, c)
	}
}
func UserUpdateProject(c *gin.Context) {
	var userProject model.UserProject
	userProject.NowStatus = 10
	_ = c.ShouldBindJSON(&userProject)
	if err := service.UpdateUserProject(userProject); err != nil {
		global.GVA_LOG.Error("申请失败!", zap.Any("err", err))
		response.FailWithMessage("申请失败", c)
	} else {
		response.OkWithMessage("申请成功", c)
	}
}
